#ifndef STRAY_GRAPHICS_DEVICE_DX9_H
#define STRAY_GRAPHICS_DEVICE_DX9_H

#ifdef _WIN32
#include <d3d9.h>
#include "../../SmartPtr/IntrusivePtr.h"
#include "../Device.h"
#include "../RenderState.h"

namespace Stray {
namespace Core {
namespace Graphics {
namespace DirectX9 {

class ContextDX9;

class DeviceDX9 : public Stray::Core::Graphics::Device
{
	friend class GraphicsSetFactoryDX9;
	friend void resetImpl(DeviceDX9 *pDevice);
private:
	DeviceDX9(IDirect3DDevice9 *pDevice);
public:
	~DeviceDX9();

	IDirect3DDevice9* getNativeDevice();

	static void resetDevice(DeviceDX9 *pThis, D3DPRESENT_PARAMETERS param);

	void reset();
	void reset(const Stray::Core::Graphics::GraphicsParameter& param);
	Stray::Core::Graphics::DeferredContextPtr createDeferredContex();
	Stray::Core::Graphics::IndexBufferPtr createIndexBuffer(size_t bufferSize, IndexBufferFormat format = IBF_INDEX16);
	Stray::Core::Graphics::VertexBufferPtr createVertexBuffer(size_t bufferSize);
	Stray::Core::Graphics::VertexLayoutPtr createVertexLayout(const Stray::Core::Graphics::VertexLayoutTables& tables);
	Stray::Core::Graphics::TexturePtr createTexture(const TextureDesc& desc);
private:
	IDirect3DDevice9 *pDevice_;
	HWND hwnd_;
};

typedef Stray::IntrusivePtr<DeviceDX9>::type DeviceDX9Ptr;

}
}
}
}

#endif // WIN32
#endif // STRAY_GRAPHICS_DEVICE_DX9_H